import 'dart:convert';

/// 类别
class Category {
  String id, label, value, sort;

  Category({this.id, this.label, this.value, this.sort});

  factory Category.fromJson(Map<String, dynamic> data) {
    return Category(
      id: data['id'],
      label: data['label'],
      value: data['value'],
      sort: data['sort']?.toString() ?? '',
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'id': id,
      'label': label,
      'value': value,
      'sort': sort,
    };
  }

  @override
  String toString() {
    return json.encode(toJson());
  }
}
